<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="/css/admin/style.css" />
<script type="text/javascript" src="/js/admin.js"></script>
<title>Insert title here</title>
<script>
function init(){
	//alert("abc");
	var parentPage = window.parent.document.getElementsByName("chose");
	//alert(document);
	var tab = document.getElementById("tab");
	//alert(tab);
	for(var i=0; i<parentPage.length; i++){
		if(parentPage[i].checked){
			//alert("check");
			var id = parentPage[i].id;
			var title = parentPage[i].title;
			var siteName = parentPage[i].getAttribute("siteName");

			//alert("id=" + id + ",title=" + title + ",siteName" + siteName);

			var tr = "<tr class=\"table-d-c\" abc>"+
				"<td><input type=\"radio\" /></td><td>"+title+"</td>"+"<td>"+siteName+"</td>"+
			    "</tr>";
		
			
			var newTr = tab.insertRow(1);
			newTr.className="table-d-c";
			newTr.onmouseover=function(){this.className="table-d-c"} 
			newTr.onmouseout=function(){this.className="td-m"}
			newTr.innerHTML = tr;
		}
	}
	
}

/**
* 将一条记录设置为主信息
*/
function setPrimary(){
	var choses = document.getElementsByName("checkID");
	if(choses==null || choses.length ==0){
		alert("请选择默认显示的信息");return false;
	}
	
	
	
	for(var i=0; i<choses.length; i++){
		if(choses[i].checked){
			//alert("title="+ choses[i].title);
			document.getElementById("primaryID").value=choses[i].title;
			return true;
		}
	}
	alert("请选择默认显示的信息");return false;
	return false;
}
</script>
</head>
<body>
	
	<form action="/admin/info/relation" method="post" onSubmit="return setPrimary();">
		<input type="hidden" name="primaryID" id="primaryID" />
	<table id="tab" width="100%" cellspacing="0" cellpadding="0" border="0" class="table_b">
		<tr class="tab-top"><td>设为默认</td><td>标题</td><td>关联数</td><td>上级ID</td><td>站点</td></tr>
		<#if infoList?exists>
			<#list infoList as info>
				<input type="hidden" id="id" name="id" value="${info.id}"/>
				<tr class="table-d-c" onmouseover='this.className="table-d-c"' onmouseout='this.className="td-m"'>
					<td align="center" width="10%"><input type="radio" name="checkID" title="${info.id}" >${info.id}</td><td>${info.title?default("")}</td>
					<td align="center">${info.subNum?default(0)}</td><td>${info.parentID?default("")}</td><td align="center">${info.siteName?default("")}</td></tr>
			</#list>
		</#if>	
	</table>
	<table>
		<tr><td><input type="submit" value="提交" /></td></tr>
	</table>
	</form>
</body>
</html>